﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using MaxStoreErp.Core.BaseClasses;

namespace MaxStoreErp.Core.Extensions
{
    public static class CollectionExtensions
    {
        public static ObservableCollection<T> ToObservableCollection<T>(this IEnumerable<T> enumerableList)
        {
            return enumerableList != null ? new ObservableCollection<T>(enumerableList) : null;
        }

        public static bool IsNullOrEmpty<TSource>(this IEnumerable<TSource> source)
        {
            return source == null || !source.Any();
        }

        public static IEnumerable<TSource> NotDeleted<TSource>(this IEnumerable<TSource> list) where TSource : EntityBase
        {
            return list != null ? list.Where(c => !c.IsDeleted) : null;
        }
    }
}
